home *** CD-ROM | disk | FTP | other *** search
/ 220 Jogos / 220 jogos.iso / classicos / resta11 / SSoundSystem.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-12-24  |  1.9 KB  |  115 lines

  1. // SSoundSystem.cpp: Implementierung der Klasse SSoundSystem.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #include "stdafx.h"
  6. #include "SSoundSystem.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char THIS_FILE[]=__FILE__;
  11. #define new DEBUG_NEW
  12. #endif
  13.  
  14. //////////////////////////////////////////////////////////////////////
  15. // Konstruktion/Destruktion
  16. //////////////////////////////////////////////////////////////////////
  17.  
  18. SSoundSystem::SSoundSystem()
  19. {
  20.     inited = false;
  21. }
  22.  
  23. SSoundSystem::~SSoundSystem()
  24. {
  25.     if (!inited)
  26.     {
  27.         return;
  28.     }
  29.  
  30.     for (int i = 0; i < NUM_SAMPLES; i += 1)
  31.     {
  32.         BASS_SampleFree(samples[i]);
  33.     }
  34.  
  35.     //BASS System runterfahren
  36.  
  37.     BASS_Free();
  38.     BASS_Stop();
  39. }
  40.  
  41. void SSoundSystem::init(HWND hWnd)
  42. {
  43.     BASS_Init(
  44.         -1,
  45.         44100,
  46.         NULL,
  47.         hWnd);
  48.  
  49.     BASS_Start();
  50.  
  51.     //******************
  52.     //WAV Samples laden
  53.     //******************
  54.  
  55.     /*samples[SAMPLE_BAUM] = BASS_SampleLoad(false,"Data/Baum.wav",
  56.         0,0,1,BASS_SAMPLE_OVER_VOL);*/
  57.     samples[SAMPLE_RELEASE] = BASS_SampleLoad(false,"Data/Absetzen.wav",
  58.         0,0,1,BASS_SAMPLE_OVER_VOL);
  59.     
  60.  
  61.     //******************
  62.     //MP3s laden
  63.     //******************
  64.  
  65.     streams[STREAM_RUDI] = BASS_StreamCreateFile(false,
  66.         "Data\\Rudi.mp3",
  67.         0,
  68.         0,
  69.         NULL);
  70.  
  71.     streams[STREAM_BELLS] = BASS_StreamCreateFile(false,
  72.         "Data\\Jingle Bells.mp3",
  73.         0,
  74.         0,
  75.         NULL);
  76.  
  77.  
  78.  
  79.  
  80.     //BASS_StreamPlay(music,false,BASS_SAMPLE_LOOP);
  81.  
  82.     inited = true;
  83. }
  84.  
  85. void SSoundSystem::playMusic(int which,bool looped)
  86. {
  87.     if (which < 0 || which > 2)
  88.     {
  89.         return;
  90.     }
  91.  
  92.     BASS_StreamPlay(streams[which],true,(looped ? BASS_SAMPLE_LOOP:0));
  93. }
  94.  
  95. void SSoundSystem::stopMusic(int which)
  96. {
  97.     if (which < 0 || which > 1)
  98.     {
  99.         return;
  100.     }
  101.  
  102.     BASS_Stop();
  103.     BASS_Start();
  104. }
  105.  
  106. void SSoundSystem::playSample(int which)
  107. {
  108.     if (which < 0 || which > NUM_SAMPLES)
  109.     {
  110.         return;
  111.     }
  112.  
  113.     BASS_SamplePlay(samples[which]);
  114. }
  115.